package com.supervision.manage.service

import com.fly.base.misc.pagination.Pagination
import com.supervision.domain.bean.po.UserSearchPO
import com.supervision.manage.mapper.UserMapper
import com.supervision.domain.model.User
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service("UserService")
class UserService : BaseService() {

    companion object {
        private val logger = org.slf4j.LoggerFactory.getLogger(UserService::class.java)
    }

    @Autowired
    lateinit var userMapper: UserMapper

    fun select(condition: User, otherCondition: String?): List<User> {
        return userMapper.select(condition, otherCondition)
    }

    fun getUserList(po: UserSearchPO): HashMap<String, Any> {
        val userList = userMapper.getUserList(po, Pagination.limitSql(po.page))
        val count = userMapper.countUserList(po, "")

        return hashMapOf<String, Any>(
                "list" to userList,
                "count" to count
        )
    }


}
